package com.lgl.study.login.controller;

import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * @Auther: Brook
 * @Date: 2020/10/13 20:49
 * @Description:
 */
@Controller
@RequestMapping("/login")
public class LoginController {

    /**
     * 定位首页
     * @return
     */
    @RequestMapping("/toLogin")
    public String toLogin() {

        return "login";
    }

    @RequestMapping("/doLogin")
    public String doLogin(HttpSession session, String userid, String password) {
        if (userid.equals("admin") && password.equals("admin")) {
            session.setAttribute("userid", "admin");
            System.out.println("登录成功!");
            return "redirect:/resume/findList";
        } else {
            System.out.println("用户名或密码错误!");
            return "redirect:/login/toLogin";
        }
    }
}
